/**
 * 群发任务内容类型枚举
 */
export enum MassSendTaskContentType {
  /** 未知消息 打开素材库 */
  MassSendTaskContentTypeUnknown = 0,
  /** 文本 */
  MassSendTaskContentTypeText = 1,
  /** 图片 */
  MassSendTaskContentTypeImage = 2,
  /** 贴纸 */
  MassSendTaskContentTypeSticker = 3,
  /** GIF */
  MassSendTaskContentTypeGif = 4,
  /** 音频 */
  MassSendTaskContentTypeAudio = 5,
  /** 语音消息 */
  MassSendTaskContentTypePtt = 6,
  /** 视频 */
  MassSendTaskContentTypeVideo = 7,
  /** 文档 */
  MassSendTaskContentTypeDocument = 8,
  /** 名片 */
  MassSendTaskContentTypeCard = 9,
  /** 扩展文本消息 */
  MassSendTaskContentTypeExtendedText = 10,
  /** 链接 */
  MassSendTaskContentTypeUrl = 11,
  /** 商户链接 */
  MassSendTaskContentTypeMerchantUrl = 12,
  /** 位置 */
  MassSendTaskContentTypeLocation = 13,
  /** 投票 */
  MassSendTaskContentTypePoll = 14,
  /** 语音通话 */
  MassSendTaskContentTypeVoiceCall = 15,
  /** 视频通话 */
  MassSendTaskContentTypeVideoCall = 16,
  /** 图文模板 */
  MassSendTaskContentTypeImageTextTemplate = 17,
}

/**
 * 消息类型（用于显示）
 */
export type MessageType =
  | "UNKNOWN"
  | "TEXT"
  | "IMAGE"
  | "VIDEO"
  | "AUDIO"
  | "PTT"
  | "DOCUMENT"
  | "STICKER"
  | "GIF"
  | "CARD"
  | "EXTENDED_TEXT"
  | "URL"
  | "MERCHANT_URL"
  | "LOCATION"
  | "VOICE_CALL"
  | "VIDEO_CALL"
  | "IMAGETEXTTEMPLATE"
  | "POLL";

/**
 * 按钮信息
 */
export interface ButtonInfo {
  /** 按钮名称（用于翻译的 key） */
  btnName: string;
  /** 图标名称 */
  icon: string;
  /** 群发任务内容类型 */
  massSendTaskContentType: MassSendTaskContentType;
}

/**
 * 内容项
 */
export interface ContentItem {
  /** 群发任务内容类型 */
  massSendTaskContentType: MassSendTaskContentType;
  /** 按钮名称（用于显示） */
  btnName: string;
  /** 图标名称 */
  icon: string;
  /** 内容 */
  taskContent: string;
  /** 内容 URL（用于图片、视频等） */
  taskContentUrl?: string;
}

/**
 * 消息显示项（传给 MessageDisplay 组件）
 */
export interface MessageDisplayItem {
  messageType: MessageType;
  messageContent: string;
  messageContentUrl?: string;
}

/**
 * 类型转换映射
 */
export const MassSendTypeToMessageType: Record<
  MassSendTaskContentType,
  MessageType
> = {
  [MassSendTaskContentType.MassSendTaskContentTypeUnknown]: "TEXT",
  [MassSendTaskContentType.MassSendTaskContentTypeText]: "TEXT",
  [MassSendTaskContentType.MassSendTaskContentTypeImage]: "IMAGE",
  [MassSendTaskContentType.MassSendTaskContentTypeSticker]: "STICKER",
  [MassSendTaskContentType.MassSendTaskContentTypeGif]: "GIF",
  [MassSendTaskContentType.MassSendTaskContentTypeAudio]: "AUDIO",
  [MassSendTaskContentType.MassSendTaskContentTypePtt]: "PTT",
  [MassSendTaskContentType.MassSendTaskContentTypeVideo]: "VIDEO",
  [MassSendTaskContentType.MassSendTaskContentTypeDocument]: "DOCUMENT",
  [MassSendTaskContentType.MassSendTaskContentTypeCard]: "CARD",
  [MassSendTaskContentType.MassSendTaskContentTypeExtendedText]:
    "EXTENDED_TEXT",
  [MassSendTaskContentType.MassSendTaskContentTypeUrl]: "URL",
  [MassSendTaskContentType.MassSendTaskContentTypeMerchantUrl]: "MERCHANT_URL",
  [MassSendTaskContentType.MassSendTaskContentTypeLocation]: "LOCATION",
  [MassSendTaskContentType.MassSendTaskContentTypePoll]: "POLL",
  [MassSendTaskContentType.MassSendTaskContentTypeVoiceCall]: "VOICE_CALL",
  [MassSendTaskContentType.MassSendTaskContentTypeVideoCall]: "VIDEO_CALL",
  [MassSendTaskContentType.MassSendTaskContentTypeImageTextTemplate]:
    "IMAGETEXTTEMPLATE",
};

/**
 * 转换群发类型到消息类型
 */
export function getMessageTypeFromMassSendType(
  type: MassSendTaskContentType
): MessageType {
  return MassSendTypeToMessageType[type] || "TEXT";
}

/**
 * 默认按钮配置
 */
export const DEFAULT_BUTTONS: ButtonInfo[] = [
  {
    btnName: "mass.addText",
    icon: "Document",
    massSendTaskContentType:
      MassSendTaskContentType.MassSendTaskContentTypeText,
  },
  {
    btnName: "mass.addImage",
    icon: "Picture",
    massSendTaskContentType:
      MassSendTaskContentType.MassSendTaskContentTypeImage,
  },
  {
    btnName: "mass.addPhone",
    icon: "PhoneFilled",
    massSendTaskContentType:
      MassSendTaskContentType.MassSendTaskContentTypeVoiceCall,
  },
  {
    btnName: "mass.addVideoPhone",
    icon: "Phone",
    massSendTaskContentType:
      MassSendTaskContentType.MassSendTaskContentTypeVideoCall,
  },
  {
    btnName: "session.materialLibrary",
    icon: "Folder",
    massSendTaskContentType:
      MassSendTaskContentType.MassSendTaskContentTypeUnknown,
  },
];
